<template>
  <el-dialog title="修改角色" width="40%" :before-close="dialogClose" :visible.sync="show">
    <el-form ref="form" label-width="80px">
        <el-form-item label="员工角色">
          <el-select v-model="roleValue" placeholder="请选择员工角色">
            <el-option v-for="(item,index) in roleArr" :key="index" :label="item.role" :value="item.id"></el-option>
          </el-select>
        </el-form-item>
        <div align="center">
          <el-button type="primary" @click="add">确定修改</el-button>
          <el-button @click="dialogClose">取 消</el-button>
        </div>
        </el-form-item>
      </el-form>
    </el-dialog>
</template>
 
<script>
export default {
  name: 'staffEdit',
  props:['show','id','roleArr','role'],
  data() {
    return {
      roleValue:this.role
    }
  },
  created: function() {
    
  },
  methods: {
    dialogClose:function(){
      this.$emit("func",{'key':'editShow'})
    },
    add:function(){
      var data = {id:this.id,role:this.roleValue}
      var that = this
      this.$post('staff/save',data).then((res) => {
          if(res.code == 1){
            that.$message.success(res.msg);
            that.$emit("func",{'key':'editShow','type':1})
          }else{
            that.$message.error(res.msg);
          }
      })
    }
  }
}
</script>